

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/app_values.dart';
import 'package:gczn_hd/flavors/build_config.dart';
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import '../../../flavors/env_config.dart';
import '../values/text_styles.dart';

mixin HandleMixin on StatelessWidget{

  final Logger logger = BuildConfig.instance.config.logger;
  final String appName = BuildConfig.instance.config.appName;



  void showToast(String msg){
    Fluttertoast.showToast(msg: msg);
  }

  void showAlert({
    String? title,
    required String content,
  }){
    Get.dialog(AlertDialog(
      title: Text(title ?? appName),
      content: Text(content),
      actions: [
        TextButton(
          onPressed: () {
            Get.back(); // 关闭弹窗
          },
          child:  Text('关闭', style: submitButtonStyle,),
        ),
      ],
    ));
  }

  void showConfirm({
    String? title,
    required String content,
    VoidCallback? onConfirm,
    VoidCallback? onCancel,
    String confirmText = '确定',
    String cancelText = '取消',
  }){
    Get.dialog(AlertDialog(
      title: Text(title ?? appName),
      content: Text(content),
      actions: [
        TextButton(
          onPressed: onCancel ?? (){Get.back();},
          child:  Text(cancelText, style:  TextStyle(color: AppColors.textColorSecondary, fontWeight: FontWeight.normal, fontSize: AppValues.circularImageSize_30.sp),),
        ),
        TextButton(
          onPressed: onConfirm ?? (){ Get.back(); },
          child:  Text(confirmText, style: successTextStyle,),
        ),
      ],
    ));
  }


}